package cn.online.zhuanshenben.service;

import cn.online.zhuanshenben.dao.SadminMapper;
import cn.online.zhuanshenben.dao.SuserMapper;
import cn.online.zhuanshenben.entity.Sadmin;
import cn.online.zhuanshenben.entity.SadminExample;
import cn.online.zhuanshenben.entity.Suser;
import cn.online.zhuanshenben.entity.SuserExample;
import cn.online.zhuanshenben.util.MybatisUtil;
import cn.online.zhuanshenben.util.StrUtil;
import cn.online.zhuanshenben.vo.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class AdminService {
    public static final AdminService ME = new AdminService();

    public Sadmin login(String u,String p) {
        SqlSession session = MybatisUtil.get();
        try {
            SadminMapper mapper = session.getMapper(SadminMapper.class);
            SadminExample admin=new SadminExample();
            SadminExample.Criteria cr = admin.createCriteria();
            cr.andSadminEqualTo(u);
            cr.andSpassEqualTo(p);
            List<Sadmin> list = mapper.selectByExample(admin);
            return list.size()==0?null:list.get(0);
        } finally {
            MybatisUtil.close(session);
        }
    }

}
